package cn.clwxy.gdz.controller.personnao;


import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.impl.bootstrap.HttpServer;

import cn.clwxy.gdz.dao.TeacherDao;
import cn.clwxy.gdz.dao.TeacherDaoImpl;
import cn.clwxy.gdz.dao.TeacherGradeDao;
import cn.clwxy.gdz.dao.TeacherGradeDaoImpl;
import cn.clwxy.gdz.dao.TeacherSubjectDao;
import cn.clwxy.gdz.dao.TeacherSubjectDaoImpl;
@WebServlet(urlPatterns={"/ChangeTeacherSubjectServlet"})
public class ChangeTeacherSubjectServlet extends HttpServlet{
	@Override

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		Integer teacherId=(Integer)request.getSession().getAttribute("id");
		String op=request.getParameter("op");
		Integer subjectId=Integer.valueOf(request.getParameter("subjectId"));
		TeacherSubjectDao teacherSubjectDao=new TeacherSubjectDaoImpl();
		int resu=0;
		if("delete".equals(op)){
			resu=teacherSubjectDao.deleteTeacherSubject(teacherId, subjectId);
		}else if("add".equals(op)){
			 resu=teacherSubjectDao.addTeacherSubject(teacherId, subjectId);
			
		}
		
		System.out.println("修改数量："+resu);
		response.getWriter().write(String.valueOf(resu));
	}
}
